from application import db

dbconfig = {
  "HOSTNAME": "127.0.0.1",
  "PORT": "3306",
  "USERNAME": "root",
  "PASSWORD": "12345678",
  "DATABASE": "test",
}
app_config = {
  "HOST": "0.0.0.0",
  "PORT": 8000,
  # 数据库连接地址
  "SQLALCHEMY_DATABASE_URI": f"mysql+pymysql://{dbconfig['USERNAME']}:{dbconfig['PASSWORD']}@{dbconfig['HOSTNAME']}:{dbconfig['PORT']}/{dbconfig['DATABASE']}?charset=utf8",
  # app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://username:password@localhost/dbname'  # MySQL 数据库
  # app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://username:password@localhost/dbname'  # PostgreSQL 数据库
  "SQLALCHEMY_TRACK_MODIFICATIONS": False,  # 配置是否追踪对象的修改并发送信号
  "SQLALCHEMY_ECHO": False,  # 查询时会显示原始SQL语句
  "DEBUG": True,
  "SECRET_KEY": "KarrySnail",
  # 把session通过SQLAlchmey保存到mysql中
  "SESSION_TYPE": "sqlalchemy",  # session类型为sqlalchemy
  "SESSION_SQLALCHEMY": db,  # SQLAlchemy的数据库连接对象
  "SESSION_SQLALCHEMY_TABLE": 'db_session',  # session要保存的表名称
  "SESSION_PERMANENT": True,  # 如果设置为True，则关闭浏览器session就失效
  "SESSION_USE_SIGNER": True,  # 是否对发送到浏览器上session的cookie值进行添加签名，防止串改。
  "SESSION_KEY_PREFIX": "session:"  # session数据表中sessionID的前缀，默认就是 session:
}